package com.moter.one.wyydemo1.mapper;

import com.moter.one.wyydemo1.entity.UserInfo;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface UserInfoMapper {
//    private String account;//账号
//    private String password;//密码
//    private String nickname;//昵称
//    private int scores;//积分
//    private String sex;//性别
//    private String signature;//个性签名
//    private String phone;//电话号码
//    private String email;//邮箱
    //插入用户数据
   @Insert("insert into userstable(account,password,nickname,scores,sex,signature,phone,email) " +
           "values(#{account},#{password},#{nickname},#{scores}," +
           "#{sex},#{signature},#{phone},#{email})")
    public int insertUserInfo(UserInfo userInfo);

    //根据传送的对象删除在数据库中的对象通过主键查找
    @Delete("delete from userstable where account = #{account}")
    public  int deleteUserInfo(UserInfo userInfo);
   //查询用户数据
    @Select("select * from userstable")
    List<UserInfo> selectUserInfo();
    //分页查询
    @Select("select * " +
            "from userstable " +
            "limit #{page},#{limit}")
    List<UserInfo> searchAllByPage(Integer page, Integer limit);

    //多条件查询
    @Select("select * from userstable " +
            "where account like concat('%',#{account},'%') " +
            "and nickname like concat('%',#{nickname},'%') " +
            "and phone like concat('%',#{phone},'%')")
    List<UserInfo> searchBy_account_nickname_phone(String account,String nickname,String phone);

    //删除用户
    @Update("delete from userstable " +
            "where account = #{account}")
    Integer deleteByAccount(String account);

    @Select("select * from userstable where account = #{account}")
    public UserInfo getUserByAccount(String account);
}
